//
//  YXFlutterUserDefault.m
//  flutter_yuanxin_Example
//
//  Created by GMS on 2020/10/15.
//  Copyright © 2020 Arthur. All rights reserved.
//

#import "YXFlutterUserDefault.h"


static NSString *const CHANNEL_NAME = @"yuanxin.flutter.io/user_default";

@implementation YXFlutterUserDefault

+ (void)flutter_UserDefault:(FlutterViewController *)vc {
    FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:CHANNEL_NAME binaryMessenger:vc.binaryMessenger];
    
    [channel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) {
      
        NSString *method = [call method];
      
        NSDictionary *arguments = [call arguments];

        if ([method isEqualToString:@"getObjc"]) { // 获取数据
            result([[NSUserDefaults standardUserDefaults] objectForKey:arguments[@"key"]]);
        } else if ([method isEqualToString:@"setObjc"]) {
            [[NSUserDefaults standardUserDefaults] setObject:arguments[@"value"] forKey:arguments[@"key"]];
        
        }
    }];
}


@end

